define(['vue','common'],function(Vue,utils){
	'use strict';


	var shopInfoView=new Vue({
		el:'#app',
		data:{
			items:'',
			userCode:'',
			sysIndex:'',
			isConstomer:'',
			userVipStatus:'',
			count:0,
			isVip:'',
			sysIndex:{
				eProportion:'0.00',
				businessNum:'0',
				jeProportion:'0.00'
			}
		},
		filters:{
			abbreviation:function(value){
				if (!value) {
					return '0.00';
				} else {
					var num = value.toFixed(3);
					return num.substring(0,num.lastIndexOf('.')+3);
				}
			},
			yesterdayMoney: function(value){
				// if (!value) {
				// 	return '1047187468.13';
				// } else {
				// 	var num = (value+1047187468.13).toFixed(3);
				// 	return num.substring(0,num.lastIndexOf('.')+3);
				// }
				return '26982222.00';
			},
			
			share: function(value){
				// if (!value) {
				// 	return '2331177.72';
				// } else {
				// 	var num = (value + 27444237.35).toFixed(3);
				// 	return num.substring(0,num.lastIndexOf('.')+3);
				// }
				return '2151259.72';
			}
		},
		created:function(){
			utils.userToken();

			var _this = this;
			
			utils.ajax(utils.getWebUrl('user/personal'),null,'POST',function(res){
				_this.items = res.data;

				//获取用户类型
				var type = res.data.userCode.slice(0,1);
				if(type === 'M'){
					_this.userTypeId = 4;
				}else{
					_this.userTypeId = 5;
				}
				utils.setData('userTypeId',_this.userTypeId);

				if(_this.userTypeId==4){
					window.location.href="userInfo.html";
				}
				if(!res.data.logoImg){
					_this.items.logoImg = '../../image/Avatar.png';
				}else{
					_this.items.logoImg = '../image/'+res.data.logoImg+'@2x.png';
				}
				//获取会员审核详情信息
				utils.ajax(utils.getWebUrl('user/examine'),null,'POST',function(res){	
					_this.userVipStatus = res.data.auditStatus;
				})
				//公告文章数量
				// utils.ajax(utils.getWebUrl('message/getCount'),null,'POST',function(res){
				// 	var count = res.data.count;
				// 	if(count <= 99){
				// 		_this.count = res.data.count;
				// 	}else{
				// 		_this.count = '99+';
				// 	}
				// })
				utils.ajax(utils.getWebUrl('shop/isShopp'),{
					phone: _this.items.phone,
				},'POST',function(res){
					var msg = res.msg
					if(msg.indexOf('不是商家') === -1){
						_this.isConstomer = true;
					}else{
						_this.isConstomer = false;
					}
				})
				//获取平台信息
				utils.ajax(utils.getWebUrl('user/sysIndex'),null,'POST',function(res){	
					_this.sysIndex = res.data;
				});
			},function(){
				$('.Pop_loading').show();
			},function(){
				$('.Pop_loading').hide();
			},function(){
				$('.Pop_loading').hide();
                $('#container').hide();
                $('.errorRefresh').show();
			});

		},
		methods:{
			popMsg: function(){
				document.body.scrollTop = 0;
				$('.Pop_BJ').fadeIn(200);
			},
			hideMsg: function(){
				$('.Pop_BJ').fadeOut(200);
			},
			toUserInfo: function(){
				var _this = this;
				utils.ajax(utils.getWebUrl('user/switchUser'),{
					type: 2
				},'POST',function(res){
					var token = res.data.token;
					utils.userToken(token);

					//获取用户类型
					var type = res.data.data.userCode.slice(0,1);
					if(type === 'M'){
						_this.userTypeId = 4;
					}else{
						_this.userTypeId = 5;
					}
					utils.setData('userTypeId',_this.userTypeId);

					window.location.href="userInfo.html";
				},function(){
					$('.Pop_loading').show();
				},function(){
					$('.Pop_loading').hide();
				})
			},
			toRefresh: function(){
				window.location.reload();
			},
			//调到会员升级
			toMemberUpgrade:function(){
				var _this = this;
				if(_this.userVipStatus == '0'){
					window.location.href="MemberUpgrade.html";
				}else if(_this.userVipStatus == '1'){
					document.body.scrollTop = 0;
					utils.appAlert('VIP会员升级中...',function(){
						
					},'知道了',null,null,'提示');
				}else{
					window.location.href="MemberUpgrade.html";
				}
			}
		}
	})

	return shopInfoView
});